package com.lwh.springboot.controller;

import com.lwh.springboot.service.IAuthService;
import com.lwh.springboot.pojo.entity.Auth;
import com.lwh.springboot.pojo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private IAuthService authService;

    @RequestMapping("/")
    public String index(HttpSession session, Model model) {
        User user = (User) session.getAttribute("user");
        List<Auth> list = authService.selectByRoleId(user.getRole());
        model.addAttribute("list", list);
        return "index";
    }

    @RequestMapping("/indexAdmin")
    public String indexAdmin() {

        return "indexadmin";
    }

    @RequestMapping("/indexUser")
    public String indexNormal() {
        return "indexuser";
    }
}
